package com.framework.modules.base.controller;

import java.util.Arrays;
import java.util.Map;

import com.framework.common.validator.ValidatorUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.framework.modules.base.entity.UserReportEntity;
import com.framework.modules.base.service.UserReportService;
import com.framework.common.utils.PageUtils;
import com.framework.common.utils.R;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;


/**
 * 举报内容表
 *
 * @author MIT
 * @email litmiss@gmail.com
 * @date 2020-10-23 11:00:12
 */
@RestController
@RequestMapping("base/userreport")
@Api(tags = "UserReportController")
public class UserReportController {
    @Autowired
    private UserReportService userReportService;

    /**
     * 列表
     */
    @RequestMapping("/list")
        @ApiOperation("list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userReportService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
        @ApiOperation("info")
    public R info(@PathVariable("id") Integer id){
        UserReportEntity userReport = userReportService.selectById(id);

        return R.ok().put("userReport", userReport);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
        @ApiOperation("save")
    public R save(@RequestBody UserReportEntity userReport){
        userReportService.insert(userReport);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
        @ApiOperation("update")
    public R update(@RequestBody UserReportEntity userReport){
        ValidatorUtils.validateEntity(userReport);
        userReportService.updateAllColumnById(userReport);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
        @ApiOperation("delete")
    public R delete(@RequestBody Integer[] ids){
        userReportService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
